#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/stat.h>
#define SIZE 10000 
int fd;

void  panic(char *message)
{
	perror(message);
	exit(EXIT_FAILURE);
}

int main(int argc, char *argv[])
{
	if(argc<2)
		panic("need file");
	char buf[SIZE];
	char* path=argv[1];
	char* path2=argv[2];
	fd=open(path, O_RDONLY);
	if(fd<0)
		panic("open");
	int Read=read(fd, buf, sizeof(buf));
	if(Read<0)
		panic("read");
	close(fd);

	int fd2=open(path2, O_CREAT| O_WRONLY| O_TRUNC, 0666);
	if(fd2<0)
		panic("open2");
	int count=write(fd2, buf, Read);
	if(count<0)
		panic("write");
	close(fd2);
	return 0;
}
